/**
 * <copyright>
 * </copyright>
 *
 */
package de.sabram.upb.specs.lido.impl;

import de.sabram.upb.specs.lido.Alts;
import de.sabram.upb.specs.lido.LidoPackage;
import de.sabram.upb.specs.lido.SyntId;
import de.sabram.upb.specs.lido.SyntUnit;
import de.sabram.upb.specs.lido.SyntUnits;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Synt Id</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.sabram.upb.specs.lido.impl.SyntIdImpl#getName <em>Name</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.SyntIdImpl#getSyntUnits <em>Synt Units</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.SyntIdImpl#getAlts <em>Alts</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SyntIdImpl extends ProductionImpl implements SyntId
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getSyntUnits() <em>Synt Units</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSyntUnits()
   * @generated
   * @ordered
   */
  protected SyntUnits syntUnits;

  /**
   * The cached value of the '{@link #getAlts() <em>Alts</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAlts()
   * @generated
   * @ordered
   */
  protected Alts alts;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected SyntIdImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return LidoPackage.Literals.SYNT_ID;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.SYNT_ID__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public SyntUnits getSyntUnits()
  {
    return syntUnits;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSyntUnits(SyntUnits newSyntUnits, NotificationChain msgs)
  {
    SyntUnits oldSyntUnits = syntUnits;
    syntUnits = newSyntUnits;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.SYNT_ID__SYNT_UNITS, oldSyntUnits, newSyntUnits);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSyntUnits(SyntUnits newSyntUnits)
  {
    if (newSyntUnits != syntUnits)
    {
      NotificationChain msgs = null;
      if (syntUnits != null)
        msgs = ((InternalEObject)syntUnits).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SYNT_ID__SYNT_UNITS, null, msgs);
      if (newSyntUnits != null)
        msgs = ((InternalEObject)newSyntUnits).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SYNT_ID__SYNT_UNITS, null, msgs);
      msgs = basicSetSyntUnits(newSyntUnits, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.SYNT_ID__SYNT_UNITS, newSyntUnits, newSyntUnits));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Alts getAlts()
  {
    return alts;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetAlts(Alts newAlts, NotificationChain msgs)
  {
    Alts oldAlts = alts;
    alts = newAlts;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.SYNT_ID__ALTS, oldAlts, newAlts);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAlts(Alts newAlts)
  {
    if (newAlts != alts)
    {
      NotificationChain msgs = null;
      if (alts != null)
        msgs = ((InternalEObject)alts).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SYNT_ID__ALTS, null, msgs);
      if (newAlts != null)
        msgs = ((InternalEObject)newAlts).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SYNT_ID__ALTS, null, msgs);
      msgs = basicSetAlts(newAlts, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.SYNT_ID__ALTS, newAlts, newAlts));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case LidoPackage.SYNT_ID__SYNT_UNITS:
        return basicSetSyntUnits(null, msgs);
      case LidoPackage.SYNT_ID__ALTS:
        return basicSetAlts(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case LidoPackage.SYNT_ID__NAME:
        return getName();
      case LidoPackage.SYNT_ID__SYNT_UNITS:
        return getSyntUnits();
      case LidoPackage.SYNT_ID__ALTS:
        return getAlts();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case LidoPackage.SYNT_ID__NAME:
        setName((String)newValue);
        return;
      case LidoPackage.SYNT_ID__SYNT_UNITS:
        setSyntUnits((SyntUnits)newValue);
        return;
      case LidoPackage.SYNT_ID__ALTS:
        setAlts((Alts)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case LidoPackage.SYNT_ID__NAME:
        setName(NAME_EDEFAULT);
        return;
      case LidoPackage.SYNT_ID__SYNT_UNITS:
        setSyntUnits((SyntUnits)null);
        return;
      case LidoPackage.SYNT_ID__ALTS:
        setAlts((Alts)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case LidoPackage.SYNT_ID__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case LidoPackage.SYNT_ID__SYNT_UNITS:
        return syntUnits != null;
      case LidoPackage.SYNT_ID__ALTS:
        return alts != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass)
  {
    if (baseClass == SyntUnit.class)
    {
      switch (derivedFeatureID)
      {
        case LidoPackage.SYNT_ID__NAME: return LidoPackage.SYNT_UNIT__NAME;
        default: return -1;
      }
    }
    return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass)
  {
    if (baseClass == SyntUnit.class)
    {
      switch (baseFeatureID)
      {
        case LidoPackage.SYNT_UNIT__NAME: return LidoPackage.SYNT_ID__NAME;
        default: return -1;
      }
    }
    return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(')');
    return result.toString();
  }

} //SyntIdImpl
